const app = getApp();
// const credict  =app.globalData.credit
Page({
  /**
   * 页面的初始数据
   */
  data: {
    un_click1: 'money_box',
    un_click2: 'money_box',
    un_click3: 'money_box',
    un_click4: 'money_box',
    un_click5: 'money_box',
    un_click6: 'money_box',
  },
  lv1: function (e) {
    this.setData({
      un_click2: 'money_box',
      un_click3: 'money_box',
      un_click4: 'money_box',
      un_click5: 'money_box',
      un_click6: 'money_box',
      un_click1: 'money_box1'
    })
    app.globalData.credit = e.currentTarget.dataset.text;
  },
  lv2: function (e) {
    this.setData({
      un_click2: 'money_box1',
      un_click3: 'money_box',
      un_click4: 'money_box',
      un_click5: 'money_box',
      un_click6: 'money_box',
      un_click1: 'money_box',
    })
    app.globalData.credit = e.currentTarget.dataset.text;
  },
  lv3: function (e) {
    this.setData({
      un_click2: 'money_box',
      un_click3: 'money_box1',
      un_click4: 'money_box',
      un_click5: 'money_box',
      un_click6: 'money_box',
      un_click1: 'money_box',
    })
    app.globalData.credit = e.currentTarget.dataset.text;
  },
  lv4: function (e) {
    this.setData({
      un_click2: 'money_box',
      un_click3: 'money_box',
      un_click4: 'money_box1',
      un_click5: 'money_box',
      un_click6: 'money_box',
      un_click1: 'money_box',
    })
    app.globalData.credit = e.currentTarget.dataset.text;
  },
  lv5: function (e) {
    this.setData({
      un_click2: 'money_box',
      un_click3: 'money_box',
      un_click4: 'money_box',
      un_click5: 'money_box1',
      un_click6: 'money_box',
      un_click1: 'money_box',
    })
    app.globalData.credit = e.currentTarget.dataset.text;
  },
  lv6: function (e) {
    this.setData({
      un_click2: 'money_box',
      un_click3: 'money_box',
      un_click4: 'money_box',
      un_click5: 'money_box',
      un_click6: 'money_box1',
      un_click1: 'money_box',
    })
    app.globalData.credit = e.currentTarget.dataset.text;
  },
  finish: function (e) {
    // console.log(getApp().globalData.userMoney)
    // console.log(getApp().globalData.userid)
    //  console.log(getApp().globalData.credit)
    var userid = getApp().globalData.userid;
    var userMoney = getApp().globalData.userMoney;
    var credit = getApp().globalData.credit;
    var mark = 'addUserMoney'
    wx.request({
      url: 'http://localhost:8080/youYanZaiXian/AppServlet',
      method: 'POST',
      data:{
        userid:userid,
        userMoney:userMoney,
        credit:credit,
        mark:mark,
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
      },
      success: (res)=>{
    var userid = getApp().globalData.userid;
    var mark = 'getUserMoney';
    wx.request({
      url: 'http://localhost:8080/youYanZaiXian/AppServlet',
      method: 'POST',
      data:{
        mark:mark,
        userid:userid,
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
      },
      success: (res)=>{
        var userMoney = res.data.data.userMoney;
        app.globalData.userMoney = userMoney;
      }
    });

      }
    });
    wx.navigateTo({
      url: '../finish/finish'
    })
  },

})